package com.frabo.watchadoin;

import android.app.Application;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.frabo.watchadoin.model.Doing;


public class WatchaDoinApplication extends Application {

    private static WatchaDoinApplication sInstance;
    public Typeface avenirFont;
    public Typeface avenirFontBold;
    public Doing currentDoing;

    public static WatchaDoinApplication getInstance() {
        return sInstance;
    }
    //-----------------------------------
    // lifecycle
    //-----------------------------------
    @Override
    public void onCreate()
    {
        super.onCreate();
        sInstance = this;
        avenirFont = Typeface.createFromAsset(getAssets(), "avenir.otf");
        avenirFontBold =Typeface.createFromAsset(getAssets(), "avenirbold.otf");
    }

    @Override
    public void onTerminate()
    {
        // not guaranteed to be called
        super.onTerminate();
    }

    //-----------------------------------
    // getters/setters
    //-----------------------------------
    public void setFont(ViewGroup group, Typeface font) {
        int count = group.getChildCount();
        View v;
        for(int i = 0; i < count; i++) {
            v = group.getChildAt(i);
            if(v instanceof TextView || v instanceof Button)
                ((TextView)v).setTypeface(font);
            else if(v instanceof ViewGroup)
                setFont((ViewGroup)v, font);
        }
    }

}
